﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using DevExpress.LookAndFeel;
using System.ServiceModel;
using System.Security.Cryptography;
using System.Text;

namespace ZgOffice.Client
{
    static class Program
    {
        public static LoginType LoginInfo = new LoginType();
        public static WSDualHttpBinding bind = null;
        public static EndpointAddress address = null;
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            DevExpress.Skins.SkinManager.EnableFormSkins();
            DevExpress.UserSkins.BonusSkins.Register();
            UserLookAndFeel.Default.SetSkinStyle("DevExpress Style");
            bind = new WSDualHttpBinding();
            address = new EndpointAddress("http://127.0.0.1:6549/Service");
            OfficeServiceClient client = new OfficeServiceClient(bind,address);
            LoginForm loginFrm = new LoginForm();
            switch(loginFrm.ShowDialog())
            {
                case DialogResult.OK:
                    Application.Run(new MainFrm());
                    break;
                case DialogResult.Retry: 
                    Application.Restart();
                    break;
                default:
                    break;
            }
        }
        /// <summary>
        /// MD5加密
        /// </summary>
        public static string getPass(string str)
        {
            MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
            byte[] encryptedBytes = md5.ComputeHash(Encoding.ASCII.GetBytes(str));
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < encryptedBytes.Length; i++)
            {
                sb.AppendFormat("{0:x2}", encryptedBytes[i]);
            }
            return sb.ToString().ToUpper();
        }
    }
}